<!--编辑设备供应-->
<template>
    <div>
        <el-row>
            <el-col :span="18">
                <el-form :inline="true" :model="formD" class="demo-form-inline">
                    <!--主营设备-->
                    <el-form :inline="true" :model="formD" class="demo-form-inline">
                        <el-form-item label="主营设备" >
                            <span v-for="item in form.deviceList " style="margin:10px">{{item}}</span>
                        </el-form-item>
                        <el-button type="info" @click="openDialog('addShebei')" style="margin-bottom:20px">设置主营设备</el-button>
                    </el-form>
                    <!--企业知名度-->
                    <el-form-item label="企业知名度">
                        <el-select v-model="formD.enterprise_popularity">
                            <el-option :label="item.name" :value="item.id" v-for="item in QYMessage"></el-option>
                        </el-select>
                    </el-form-item>
                </el-form>
                <!--售后网络覆盖区域-->
                <el-form :inline="true" :model="form" class="demo-form-inline">
                    <el-form-item label="售后网络覆盖区域">
                        <span v-for="item in form.provinceOptions" style="margin:10px">{{item}}</span>
                    </el-form-item>
                    <el-button type="info" @click="openDialog('addArea')" style="margin-bottom:20px">设置区域</el-button>
                </el-form>
                <!--市场占有率-->
                <el-form :inline="true" :model="formD" class="demo-form-inline">
                    <el-form-item label="市场占有率">
                        <el-input v-model="formD.market_share" placeholder="市场占有率"></el-input>
                    </el-form-item>
                    <span style="font-size: 25px">%</span>
                </el-form>
                <!--销售方式-->
                <el-form :inline="true" :model="formD" class="demo-form-inline">
                    <el-form-item label="特殊能力">
                        <template>
                            <el-checkbox-group v-model="formD.sale_way">
                                <el-checkbox label="1">直销</el-checkbox>
                                <el-checkbox label="2">代理</el-checkbox>
                                <el-checkbox label="3">EPC</el-checkbox>
                                <el-checkbox label="4">其他</el-checkbox>
                            </el-checkbox-group>
                        </template>
                    </el-form-item>
                </el-form>
                <!--添加关键人物-->
                <h3>关键人物</h3>
                <el-form :inline="true"  class="demo-form-inline" v-for="(item,index) in keyManmessage" style="padding-left: 80px">
                    <el-form-item >
                        <el-select v-model="entrepot[index].name" placeholder="请选择">
                            <el-option
                                    v-for="data in item.man"
                                    :label="data.label"
                                    :value="data.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="职务">
                        <el-select v-model="entrepot[index].status" placeholder="请选择">
                            <el-option
                                    v-for="data in item.man"
                                    :key="data.value"
                                    :label="data.label"
                                    :value="data.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-button type="text" @click="delMan(index)">移除</el-button>
                </el-form>
                <el-button type="info" @click="addMan" style="margin-left: 80px">添加人物</el-button>
            </el-col>
            <el-col :span="1">
                <hr style="height:200px;width: 1px">
            </el-col>
            <el-col :span="5"><div >
                <h2>评价星级</h2>
                <el-form :inline="true" :model="formD" class="demo-form-inline">
                    <el-form-item>
                        <el-select v-model="formD.device_evaluate_star" placeholder="评价星级">
                            <el-option label="一星" value="1"></el-option>
                            <el-option label="二星" value="2"></el-option>
                            <el-option label="三星" value="3"></el-option>
                            <el-option label="四星" value="4"></el-option>
                            <el-option label="五星" value="5"></el-option>
                        </el-select>
                    </el-form-item>
                </el-form>
            </div></el-col>
        </el-row>
        <!--设备供应-->
        <el-dialog title="设备供应选项" :visible.sync="dialog.addShebei.open" v-if="dialog.addShebei.open" :modal="false" top="65%" size="small">
            <template>
                <!--设备选项-->
                <el-checkbox-group v-model="formD.main_equipment">
                    <el-checkbox :label="item.id" v-for="item in SBMessage" style="margin: 10px">{{item.name}}</el-checkbox>
                </el-checkbox-group>
                <el-button type="primary" size="small" @click="commit('addShebei')">确定</el-button>
            </template>
        </el-dialog>
        <!--省份选项-->
        <el-dialog title="售后网络覆盖区域" :visible.sync="dialog.addArea.open" v-if="dialog.addArea.open" :modal="false" top="65%" size="small">
            <template>
                <el-checkbox-group v-model="formD.sh_network_cover_region">
                    <el-checkbox :label="item.district_id" v-for="item in quyuBox" style="margin: 10px">{{item.district}}</el-checkbox>
                </el-checkbox-group>
                <el-button type="primary" size="small" @click=" addProvince('addArea')">确定</el-button>
            </template>
        </el-dialog>
        <div style="width:100px;margin-left:80%">
            <el-button type="warning" @click="sendFormD">保存能力</el-button>
        </div>
    </div>
</template>
<script>
    import Bus from '@/config/bus.js'
    import _http from '@/components/common/http.vue'
    import _param from '@/components/common/param.vue'
    export default {
        data() {
            return {
                apiPort:{
//                    资质类别列表
                    qiYe:'MyProject/diction/getEnterpriseType',
//                    资质颁发单位列表
                    aptitudeawardList:'MyProject/diction/getEnterpriseType',
//                    资质等级列表
                    aptitudelevelList:'MyProject/diction/getEnterpriseType',

                    quyuApi:'MyProject/diction/getProince',
                    sheBei:'adminApi/dicTree'
//
                },
                formD:{
                    main_equipment:[],
                    enterprise_popularity:'',
                    sh_network_cover_region:[],
                    market_share:'',
                    sale_way:[],
                    device_evaluate_star:'',
                },
                form:{
                    provinceOptions:[],
                    provinceList:[],
                    deviceList:[],
                    checkList: [],
//                    企业知名度列表
                    companypopularityList:'',
                    popularity:''
                },
                //                关键人物信息存储
                entrepot:[{name:'',status:''}],
                keyManmessage:[{
                    man:[
                        {
                            value: '选项4',
                            label: '人物一'
                        }, {
                            value: '选项5',
                            label: '人物二'
                        }
                    ],
                    duty:[
                        {
                            value: '选项4',
                            label: '人物三'
                        },
                        {
                            value: '选项5',
                            label: '人物四'
                        }
                    ]}
                ],
//                里面放省份
                dialog:{
                    addShebei:{
                        open:false
                    },
                    addArea:{
                        open:false
                    }
                },
                checkList:[],
                information:{
                    classes:'综合',
                    issued:'住建部',
                    grade:'甲级',
                    charge:'100000元每案',
                    professField:'土地规划，环保设计',
                    keyMan1:'俞兆洪-总裁/CEO-18058715658',
                    keyMan2:'吴高翔-销售-18058715658'
                },
                QYMessage:'',
                quyuBox:'',
                SBMessage:''
            }
        },
        mounted(){
            this.getDicdata()
        },
        methods:{
            //            传递参数的方法
            sendFormD(){
                var that = this
                setTimeout(function(){
                    Bus.$emit("submitFormSb",that.formD)
                    that.$message({
                        message: '保存成功',
                        type: 'success'
                    });
                },200)
            },
            getDicdata(){
                var that = this
                //      资质类别
                var paramCom={code:"qyzmd"}
                var paramsCom = that.querystring.stringify(paramCom)
                _http.axiosRequest(that,that.apiPort.qiYe,paramsCom,(res)=>{
                    that.QYMessage=res.data.data
            })
//                获取区域字典
                _http.axiosRequest(that,that.apiPort.quyuApi,{},(res)=>{
                    console.log("quyu")
                console.log(res.data.data)
                that.quyuBox=res.data.data
            })
//                设备类型
                var paramSb={code:"device_lx"}
                var paramsSb = that.querystring.stringify(paramSb)
                _http.axiosRequest(that,that.apiPort.qiYe,paramsSb,(res)=>{
                    that.SBMessage=res.data.data
            })
            },
            addMan(){
                this.entrepot.push(
                        {name:'',status:''}
                )
                this.keyManmessage.push(
                        {
                            man:[
                                {
                                    value: '选项4',
                                    label: '人物一'
                                }, {
                                    value: '选项5',
                                    label: '人物二'
                                }
                            ],
                            duty:[
                                {
                                    value: '选项4',
                                    label: '经理'
                                },
                                {
                                    value: '选项5',
                                    label: 'CEO'
                                }
                            ]}
                )
            },
            commit(addField){
                this.form.deviceList=[]
                var fie = this.SBMessage
                var che = this.formD.main_equipment
                for(var i in che){
                    for(var j in fie){
                        if(fie[j].id==che[i]){
                            this.form.deviceList.push(fie[j].name)
                        }
                    }
                }
//                this.form.deviceList=this.form.checkList
                this.dialog[addField].open = false
            },
            addProvince(addField){
                this.form.provinceOptions=[]
                var fie = this.quyuBox
                var che = this.formD.sh_network_cover_region
                for(var i in che){
                    for(var j in fie){
                        if(fie[j].district_id==che[i]){
                            this.form.provinceOptions.push(fie[j].district)
                        }
                    }
                }
                this.dialog[addField].open = false
            },
            delMan(index){
                this.entrepot.splice(index,1)
                this.keyManmessage.splice(index,1)
            },
            openDialog(dialog){

                this.dialog[dialog].open = true
            }
        }
    }
</script>